/**
 * Toast 提示
 */
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { View, Text, StyleSheet, Image } from 'react-native'
import { ScaleS, ScaleT } from 'src/utils/ScreenUtil'
import CustomButton from '../button/CustomButton'

export default class CustomNavigationHeader extends PureComponent {
  static propTypes = {
    children: PropTypes.node,
    goBack: PropTypes.func
  }

  render () {
    const { children } = this.props
    return (
      <View style={styles.customHeaderInner}>
        <CustomButton style={styles.backBtn} onPress={this.backBtnClick}>
          <Image
            style={styles.backImg}
            source={require('@/imgC/home/btnBack.png')}
          />
        </CustomButton>
        {children}
      </View>
    )
  }

  backBtnClick = () => {
    const { goBack } = this.props
    goBack && goBack()
  }
}

const styles = StyleSheet.create({
  customHeaderInner: {
    position: 'relative',
    width: '100%',
    height: ScaleS(44),
    // flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center'
  },

  backBtn: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: ScaleS(60),
    paddingLeft: ScaleS(20),
    justifyContent: 'center',
    alignItems: 'flex-start',
    height: '100%'
  },
  backImg: {
    width: ScaleS(19),
    height: ScaleS(13),
    resizeMode: 'contain'
  }
})
